package com.zhibang.report.controller;


import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import com.sannuo.common.domain.bo.Cs;
import com.sannuo.common.domain.bo.Cs1;
import com.sannuo.common.result.Result;
import com.sannuo.common.result.ResultCode;

import com.zhibang.report.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/gh")
public class ReportController {
    @Autowired
    private ReportService reportService;


    @RequestMapping(value = "ghhs",method = RequestMethod.GET)
    public Result ss2(String searchParams, Integer page, Integer limit) throws Exception{
        System.out.println("谷瀚"+searchParams);
        Cs1 cs=null;
        if(searchParams!=null){
            cs = new ObjectMapper().readValue(searchParams, Cs1.class);
        }
       Page page1 = PageHelper.startPage(page, limit);
        List<Cs> cs1 = reportService.selectPatientPage1(cs);
        System.out.println("多表："+cs1);
        return Result.ok(ResultCode.SUCCESS,page1.getTotal(),cs1);
    }
    @RequestMapping(value = "ghhs1",method = RequestMethod.GET)
    public Result ss3(){
        List<Cs> cs = reportService.selectStore();
        System.out.println("谷瀚"+cs);
        return Result.ok(ResultCode.SUCCESS,cs);
    }
    @RequestMapping(value = "aress",method = RequestMethod.GET)
    public Result ss4(){
        List<Cs> cs = reportService.selectAddress();
        System.out.println("牛逼"+cs);
        return Result.ok(ResultCode.SUCCESS,cs);
    }
}
